package com.ht.base.system.biz.convert;


import java.util.ArrayList;
import java.util.List;

import com.ht.base.system.common.pojo.bo.OnOffConfBO;
import com.ht.base.system.dao.domain.OnOffConfDO;
import org.apache.commons.collections.CollectionUtils;

/**
 * BO与DO实体类转换
 * 系统开关配置对象 on_off_conf
 * @author hdengxian
 *  @date 2024-03-28
 */
public class OnOffConfBeanUtil {

    public static OnOffConfDO convertToDO(OnOffConfBO srcObj) {
        OnOffConfDO targetObj = new OnOffConfDO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setId(srcObj.getOnOffConfId());//$column.columnComment
        targetObj.setConfDesc(srcObj.getConfDesc());//开关说明
        targetObj.setConfMark(srcObj.getConfMark());//开关标识
        targetObj.setOpenStatus(srcObj.getOpenStatus());//开启状态(0-关闭，1-开启)
        targetObj.setCreateBy(srcObj.getCreateBy());//创建人
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        targetObj.setRemark(srcObj.getRemark());//备注
        return targetObj;
    }

    public static OnOffConfBO convertToBO(OnOffConfDO srcObj) {
        OnOffConfBO targetObj = new OnOffConfBO();
        if (srcObj == null) {
            return targetObj;
        }

        targetObj.setOnOffConfId(srcObj.getId());//$column.columnComment
        targetObj.setConfDesc(srcObj.getConfDesc());//开关说明
        targetObj.setConfMark(srcObj.getConfMark());//开关标识
        targetObj.setOpenStatus(srcObj.getOpenStatus());//开启状态(0-关闭，1-开启)
        targetObj.setCreateBy(srcObj.getCreateBy());//创建人
        targetObj.setCreateTime(srcObj.getCreateTime());//创建时间
        targetObj.setUpdateTime(srcObj.getUpdateTime());//更新时间
        targetObj.setRemark(srcObj.getRemark());//备注
        return targetObj;
    }

    public static List<OnOffConfBO> convertToBOList(List<OnOffConfDO> doList) {
        List<OnOffConfBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }

        doList.stream().forEach(d -> boList.add(OnOffConfBeanUtil.convertToBO(d)));
        return boList;
    }

    public static List<OnOffConfDO> convertToDOList(List<OnOffConfBO> boList) {
        List<OnOffConfDO> doList = new ArrayList<>();
        if (CollectionUtils.isEmpty(boList)) {
            return doList;
        }

        boList.stream().forEach(b -> doList.add(OnOffConfBeanUtil.convertToDO(b)));
        return doList;
    }

}